/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TimKiemHSJInternalFrame.java
 *
 * Created on Jul 29, 2010, 1:31:11 PM
 */

package GUI;

import BUS.DiemHocTapBUS;
import BUS.HocSinhBUS;
import BUS.NamHocBUS;
import POJO.HocSinhPOJO;
import POJO.NamHocPOJO;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 * @author
 *  ITEC.HCMUS.EDU.VN
 *  Ngô Huy Đạt
 *  0869005
 *  nhdat.itec@gmail.com
 */
public class TimKiemHSJInternalFrame extends javax.swing.JInternalFrame {

    public void setYearForComboBoxs(){
        DefaultComboBoxModel nm = new DefaultComboBoxModel();
        //ngay he thong
        Date d = new Date(System.currentTimeMillis());
        SimpleDateFormat dayFormat= new SimpleDateFormat("yyyy");
        int thisyear = Integer.parseInt(dayFormat.format(d.getTime()));
        for(int i=thisyear-30;i<=thisyear;i++){
            nm.addElement(String.valueOf(i));
        }
        this.jCBNam.setModel(nm);
    }


    public void showListThongTin(String MaHS, String TenHS, String GioiTinh, String NgaySinhSQL, String DiaChi,String Email){
        try {
            boolean type = this.jRBTimTuongDoi.isSelected();
            ArrayList<HocSinhPOJO> hs = HocSinhBUS.search(MaHS, TenHS, GioiTinh, NgaySinhSQL, DiaChi, Email,type);
            DefaultTableModel dt = new DefaultTableModel() {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return false;
                }
            };
            dt.addColumn("STT");
            dt.addColumn("Mã học sinh");
            dt.addColumn("Họ và Tên");
            dt.addColumn("Ngày sinh");
            dt.addColumn("Giới tính");
            dt.addColumn("Địa chỉ");
            dt.addColumn("Email");
            dt.setRowCount(hs.size());
            for (int i = 0; i < hs.size(); i++) {
                dt.setValueAt(i + 1, i, 0);
                dt.setValueAt(hs.get(i).getMaHS(), i, 1);
                dt.setValueAt(hs.get(i).getTenHS(), i, 2);
                String[] Temp = hs.get(i).getNgaySinh().split("-");
                String NgaySinh = String.format("%s-%s-%s", Temp[2],Temp[1],Temp[0]);
                dt.setValueAt(NgaySinh, i, 3);
                dt.setValueAt(hs.get(i).getGioiTinh(), i, 4);
                dt.setValueAt(hs.get(i).getDiaChi(), i, 5);
                dt.setValueAt(hs.get(i).getEmail(), i, 6);
            }
            this.jTDanhSach.setModel(dt);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }

    public void showListHocTap(String MaHS, String TenHS, String GioiTinh, String NgaySinhSQL, String DiaChi,String Email){
        try {
            boolean type = this.jRBTimTuongDoi.isSelected();
            ArrayList<HocSinhPOJO> hs = HocSinhBUS.search(MaHS, TenHS, GioiTinh, NgaySinhSQL, DiaChi, Email,type);
            DefaultTableModel dtm = new DefaultTableModel() {
                @Override
                public boolean isCellEditable(int row, int column) {
                    return false;
                }
            };
            dtm.addColumn("STT");
            dtm.addColumn("Mã học sinh");
            dtm.addColumn("Họ và Tên");
            dtm.addColumn("Lớp");
            dtm.addColumn("TB học kỳ 1");
            dtm.addColumn("TB học kỳ 2");
            dtm.setRowCount(hs.size());
            for (int i = 0; i < hs.size(); i++) {
                dtm.setValueAt(i + 1, i, 0);
                dtm.setValueAt(hs.get(i).getMaHS(), i, 1);
                dtm.setValueAt(hs.get(i).getTenHS(), i, 2);
                ArrayList<NamHocPOJO> NHList = NamHocBUS.selectAll();
                int num = NHList.size();

                double hk1 = DiemHocTapBUS.averageHK(hs.get(i).getMaHS(), "1", NHList.get(num-1).getMaNamHoc());
                if(hk1==-1){
                    dtm.setValueAt("- -", i, 4);

                }else{
                    dtm.setValueAt(String.format("%.1f", hk1), i, 4);
                }
                double hk2 = DiemHocTapBUS.averageHK(hs.get(i).getMaHS(), "2", NHList.get(num-1).getMaNamHoc());
                if(hk2==-1){
                    dtm.setValueAt("- -", i, 5);
                }else{
                    dtm.setValueAt(String.format("%.1f", hk2), i, 5);
                }
            }
            this.jTDanhSach.setModel(dtm);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }

    public void timKiem(){
        String MaHS = this.jTFMaHS.getText();
        String TenHS = this.jTFTenHS.getText();
        String GioiTinh;
        String NgaySinhSQL;
        if(this.jCBGioiTinh.isEnabled()){
            GioiTinh = (String)this.jCBGioiTinh.getSelectedItem();
        }else{//Not Enable
            GioiTinh = "";
        }
        if(this.jCBNgay.isEnabled() || this.jCBThang.isEnabled() || this.jCBNam.isEnabled()){
            String Ngay = (String)this.jCBNgay.getSelectedItem();
            String Thang = (String)this.jCBThang.getSelectedItem();
            String Nam = (String)this.jCBNam.getSelectedItem();
            NgaySinhSQL = String.format("%s-%s-%s",Nam,Thang,Ngay);
        }else{ //Not Enable
            NgaySinhSQL = "";
        }
        String DiaChi = this.jTFDiaChi.getText();
        String Email = this.jTFEmail.getText();
        this.showListThongTin(MaHS, TenHS, GioiTinh, NgaySinhSQL, DiaChi, Email);
    }

    /** Creates new form TimKiemHSJInternalFrame */
    public TimKiemHSJInternalFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        jCMaHS = new javax.swing.JCheckBox();
        jTFMaHS = new javax.swing.JTextField();
        jCTenHS = new javax.swing.JCheckBox();
        jTFTenHS = new javax.swing.JTextField();
        jCDiaChi = new javax.swing.JCheckBox();
        jTFDiaChi = new javax.swing.JTextField();
        jCEmail = new javax.swing.JCheckBox();
        jTFEmail = new javax.swing.JTextField();
        jCNgaySinh = new javax.swing.JCheckBox();
        jCBNgay = new javax.swing.JComboBox();
        jCBThang = new javax.swing.JComboBox();
        jCBNam = new javax.swing.JComboBox();
        jBTim = new javax.swing.JButton();
        jBThoat = new javax.swing.JButton();
        jCGioiTinh = new javax.swing.JCheckBox();
        jCBGioiTinh = new javax.swing.JComboBox();
        jRBTimTuongDoi = new javax.swing.JRadioButton();
        jRBChinhXac = new javax.swing.JRadioButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTDanhSach = new javax.swing.JTable();
        jRBThongTin = new javax.swing.JRadioButton();
        jRBDiemHocTap = new javax.swing.JRadioButton();
        jBHienTatCa = new javax.swing.JButton();

        setTitle("Quản lý học sinh - Tìm kiếm học sinh");
        addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
                formInternalFrameOpened(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 102, 255));
        jLabel1.setText("Tìm Kiếm Học Sinh");

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Thông tin", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 11), new java.awt.Color(0, 51, 255))); // NOI18N

        jCMaHS.setText("Mã học sinh:");
        jCMaHS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCMaHSActionPerformed(evt);
            }
        });

        jTFMaHS.setEnabled(false);

        jCTenHS.setSelected(true);
        jCTenHS.setText("Tên học sinh:");
        jCTenHS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCTenHSActionPerformed(evt);
            }
        });

        jCDiaChi.setText("Địa chỉ:");
        jCDiaChi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCDiaChiActionPerformed(evt);
            }
        });

        jTFDiaChi.setEnabled(false);

        jCEmail.setText("Email:");
        jCEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCEmailActionPerformed(evt);
            }
        });

        jTFEmail.setEnabled(false);
        jTFEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFEmailActionPerformed(evt);
            }
        });

        jCNgaySinh.setText("Ngày sinh:");
        jCNgaySinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCNgaySinhActionPerformed(evt);
            }
        });

        jCBNgay.setEnabled(false);

        jCBThang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));
        jCBThang.setEnabled(false);
        jCBThang.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCBThangItemStateChanged(evt);
            }
        });

        jCBNam.setEnabled(false);

        jBTim.setText("Tìm");
        jBTim.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBTimActionPerformed(evt);
            }
        });

        jBThoat.setText("Thoát");

        jCGioiTinh.setText("Giới tính:");
        jCGioiTinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCGioiTinhActionPerformed(evt);
            }
        });

        jCBGioiTinh.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nam", "Nữ" }));
        jCBGioiTinh.setEnabled(false);

        buttonGroup2.add(jRBTimTuongDoi);
        jRBTimTuongDoi.setSelected(true);
        jRBTimTuongDoi.setText("Tìm kiếm tương đối");
        jRBTimTuongDoi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRBTimTuongDoiActionPerformed(evt);
            }
        });

        buttonGroup2.add(jRBChinhXac);
        jRBChinhXac.setText("Tìm kiếm chính xác");
        jRBChinhXac.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRBChinhXacActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCMaHS)
                            .addComponent(jCTenHS)
                            .addComponent(jCNgaySinh))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTFTenHS, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                            .addComponent(jTFMaHS, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jCBNgay, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCBThang, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jCBNam, 0, 59, Short.MAX_VALUE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCGioiTinh)
                            .addComponent(jCDiaChi)
                            .addComponent(jCEmail))
                        .addGap(4, 4, 4)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTFDiaChi, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                            .addComponent(jTFEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
                            .addComponent(jCBGioiTinh, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jBThoat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jBTim, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(124, 124, 124)
                        .addComponent(jRBTimTuongDoi)
                        .addGap(18, 18, 18)
                        .addComponent(jRBChinhXac)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCMaHS)
                            .addComponent(jTFMaHS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTFTenHS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCTenHS))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCBNgay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCBThang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCBNam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jCNgaySinh)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jBTim)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jBThoat))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCGioiTinh)
                            .addComponent(jCBGioiTinh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCDiaChi)
                            .addComponent(jTFDiaChi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jCEmail)
                            .addComponent(jTFEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRBTimTuongDoi)
                    .addComponent(jRBChinhXac)))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Kết quả tìm kiếm", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 11), new java.awt.Color(0, 51, 204))); // NOI18N

        jTDanhSach.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(jTDanhSach);

        buttonGroup1.add(jRBThongTin);
        jRBThongTin.setSelected(true);
        jRBThongTin.setText("Hiển thị thông tin học sinh");

        buttonGroup1.add(jRBDiemHocTap);
        jRBDiemHocTap.setText("Hiển thị kết quả học tập");

        jBHienTatCa.setText("Hiện tất cả");
        jBHienTatCa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBHienTatCaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 566, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addComponent(jRBThongTin)
                .addGap(31, 31, 31)
                .addComponent(jRBDiemHocTap)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 120, Short.MAX_VALUE)
                .addComponent(jBHienTatCa, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(31, 31, 31))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBHienTatCa)
                    .addComponent(jRBThongTin)
                    .addComponent(jRBDiemHocTap))
                .addGap(6, 6, 6)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 602, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(210, 210, 210)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTFEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFEmailActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTFEmailActionPerformed

    private void jCBThangItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCBThangItemStateChanged
        // TODO add your handling code here:
        DefaultComboBoxModel ngay = new DefaultComboBoxModel();
        String tg = this.jCBThang.getSelectedItem().toString();
        if(tg.equals("02")){
            for(int i=1;i<=29;i++){
                String temp = String.valueOf(i);
                if(i<10){
                    temp = String.format("0%s",i);
                }
                 ngay.addElement(temp);
            }
        }
        else if(tg.equals("04") || tg.equals("06") || tg.equals("09") || tg.equals("11")){
            for(int i=1;i<=30;i++){
                String temp = String.valueOf(i);
                if(i<10){
                    temp = String.format("0%s",i);
                }
                ngay.addElement(temp);
            }
        }
        else{
            for(int i=1;i<=31;i++){
                String temp = String.valueOf(i);
                if(i<10){
                   temp = String.format("0%s",i);
                }
                ngay.addElement(temp);
            }
        }
         this.jCBNgay.setModel(ngay);
    }//GEN-LAST:event_jCBThangItemStateChanged

    private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_formInternalFrameOpened
        // TODO add your handling code here:
        this.setYearForComboBoxs();
        this.jCBThangItemStateChanged(null);
    }//GEN-LAST:event_formInternalFrameOpened

    private void jBTimActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBTimActionPerformed
        // TODO add your handling code here:
        this.timKiem();
    }//GEN-LAST:event_jBTimActionPerformed

    private void jBHienTatCaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBHienTatCaActionPerformed
        // TODO add your handling code here:
        this.jCMaHS.setSelected(false);
        this.jCTenHS.setSelected(false);
        this.jCNgaySinh.setSelected(false);
        this.jCGioiTinh.setSelected(false);
        this.jCDiaChi.setSelected(false);
        this.jCEmail.setSelected(false);

        this.jCMaHSActionPerformed(evt);
        this.jCTenHSActionPerformed(evt);
        this.jCNgaySinhActionPerformed(evt);
        this.jCGioiTinhActionPerformed(evt);
        this.jCDiaChiActionPerformed(evt);
        this.jCEmailActionPerformed(evt);

        this.timKiem();

    }//GEN-LAST:event_jBHienTatCaActionPerformed

    private void jCTenHSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCTenHSActionPerformed
        // TODO add your handling code here:
        this.jTFTenHS.setEnabled(this.jCTenHS.isSelected());
        if(this.jCTenHS.isSelected()==false){
            this.jTFTenHS.setText("");
        }
    }//GEN-LAST:event_jCTenHSActionPerformed

    private void jCNgaySinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCNgaySinhActionPerformed
        // TODO add your handling code here:
        this.jCBNgay.setEnabled(this.jCNgaySinh.isSelected());
        this.jCBThang.setEnabled(this.jCNgaySinh.isSelected());
        this.jCBNam.setEnabled(this.jCNgaySinh.isSelected());
    }//GEN-LAST:event_jCNgaySinhActionPerformed

    private void jCGioiTinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCGioiTinhActionPerformed
        // TODO add your handling code here:
        this.jCBGioiTinh.setEnabled(this.jCGioiTinh.isSelected());
    }//GEN-LAST:event_jCGioiTinhActionPerformed

    private void jCDiaChiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCDiaChiActionPerformed
        // TODO add your handling code here:
        this.jTFDiaChi.setEnabled(this.jCDiaChi.isSelected());
        if(this.jCDiaChi.isSelected()==false){
            this.jTFDiaChi.setText("");
        }
    }//GEN-LAST:event_jCDiaChiActionPerformed

    private void jCEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCEmailActionPerformed
        // TODO add your handling code here:
        this.jTFEmail.setEnabled(this.jCEmail.isSelected());
        if(this.jCEmail.isSelected()==false){
            this.jTFEmail.setText("");
        }
    }//GEN-LAST:event_jCEmailActionPerformed

    private void jCMaHSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCMaHSActionPerformed
        // TODO add your handling code here:
        this.jTFMaHS.setEnabled(this.jCMaHS.isSelected());
        if(this.jCMaHS.isSelected()==false){
            this.jTFMaHS.setText("");
        }
    }//GEN-LAST:event_jCMaHSActionPerformed

    private void jRBTimTuongDoiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRBTimTuongDoiActionPerformed
        // TODO add your handling code here:
        this.timKiem();
    }//GEN-LAST:event_jRBTimTuongDoiActionPerformed

    private void jRBChinhXacActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRBChinhXacActionPerformed
        // TODO add your handling code here:
        this.timKiem();
    }//GEN-LAST:event_jRBChinhXacActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jBHienTatCa;
    private javax.swing.JButton jBThoat;
    private javax.swing.JButton jBTim;
    private javax.swing.JComboBox jCBGioiTinh;
    private javax.swing.JComboBox jCBNam;
    private javax.swing.JComboBox jCBNgay;
    private javax.swing.JComboBox jCBThang;
    private javax.swing.JCheckBox jCDiaChi;
    private javax.swing.JCheckBox jCEmail;
    private javax.swing.JCheckBox jCGioiTinh;
    private javax.swing.JCheckBox jCMaHS;
    private javax.swing.JCheckBox jCNgaySinh;
    private javax.swing.JCheckBox jCTenHS;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JRadioButton jRBChinhXac;
    private javax.swing.JRadioButton jRBDiemHocTap;
    private javax.swing.JRadioButton jRBThongTin;
    private javax.swing.JRadioButton jRBTimTuongDoi;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTDanhSach;
    private javax.swing.JTextField jTFDiaChi;
    private javax.swing.JTextField jTFEmail;
    private javax.swing.JTextField jTFMaHS;
    private javax.swing.JTextField jTFTenHS;
    // End of variables declaration//GEN-END:variables

}
